<?php

session_start();
$uid = $_SESSION['id'];
$name =$_POST['name'];
$phone =$_POST['phone'];
$addr =$_POST['location'];
$sid = $_SESSION['sid'];
//echo $sid;
if (empty($sid)){
    echo "<script>alert('当前无正在进行的订单，是否返回购物车!');window.location='cart.php';</script>";

}else{
//    insert into `order`(userid,cartid,name,phone,addr) values (15,2,'陶','18882','地点')
    include_once ("mysql_conn.php");
    (new mysql_conn())->add_upadate("insert into `order`(userid,cartid,name,phone,addr) values (".$uid.",".$sid.",'".
    "".$name."','".$phone."','".$addr."')");
//    echo "insert into `order`(userid,cartid,name,phone,addr) values (".$uid.",".$sid.",'".
//        "".$name."','".$phone."','".$addr."')";
    echo "<script>alert('下单成功等待商家接单!');window.location='homeCustomerOrders.php';</script>";
    unset($_SESSION['sid']);
}
?>